home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
VISUALBA
/
VBSETUPK.ZIP
/
SETUP1.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-10-14
|
27KB
|
787 lines
Dim gGroupName As String ' Contains the ProgMan group name for the application
Sub AddShareIfNeeded (SharePath$, ShareFile$)
On Error GoTo ShareError
fh% = FreeFile
Open "C:\AUTOEXEC.BAT" For Input As fh%
fFound% = 0
While Not fFound% And Not EOF(fh%)
Line Input #fh%, Temp1$
If InStr(1, UCase$(Temp1$), "REM") = 0 And InStr(1, Temp1$, ";") = 0 And InStr(1, UCase$(Temp1$), "SHARE") > 0 Then
fFound% = True
End If
Wend
Close #fh%
If Not fFound% Then
MsgBox "Please add <PATH>SHARE.EXE /L:500 to your AUTOEXEC.BAT"
End If
Exit Sub
ShareError:
Close #fh%, #fh2%
Exit Sub
End Sub
'-------------------------------------------------------
' Centers the passed form just above center on the screen
'-------------------------------------------------------
Sub CenterForm (x As Form)
Screen.MousePointer = 11
x.Top = (Screen.Height * .85) / 2 - x.Height / 2
x.Left = Screen.Width / 2 - x.Width / 2
Screen.MousePointer = 0
End Sub
Sub ConcatSplitFiles (firstfile$, cSplit%)
Dim x%, fh1%, fh2%, outfile$, outfileLen&, CopyLeftOver&, CopyChunk#, filevar$
Dim iFileMax%, iFile%, y%
For x% = 2 To cSplit%
fh1% = FreeFile
Open Left$(firstfile$, Len(firstfile$) - 1) + Format$(1) For Binary As fh1%
fh2% = FreeFile
outfile$ = Left$(firstfile$, Len(firstfile$) - 1) + Format$(x%)
Open outfile$ For Binary As fh2%
' Goto the end of file (plus one bytes) to start writing data
Seek #fh1%, LOF(fh1%) + 1
outfileLen& = LOF(fh2%)
CopyLeftOver& = outfileLen& Mod 100
CopyChunk# = (outfileLen& - CopyLeftOver&) / 100
filevar$ = String$(CopyLeftOver&, 32)
Get #fh2%, , filevar$
Put #fh1%, , filevar$
filevar$ = String$(CopyChunk#, 32)
iFileMax% = 100
For iFile% = 1 To iFileMax%
Get #fh2%, , filevar$
Put #fh1%, , filevar$
Next iFile%
Close fh1%, fh2%
y% = SetTime(outfile$, firstfile$)
Kill outfile$
Next x%
FileCopy Left$(firstfile$, Len(firstfile$) - 1) + Format$(1), firstfile$
Kill Left$(firstfile$, Len(firstfile$) - 1) + Format$(1)
End Sub
'---------------------------------------------------------------
' Copies file SrcFilename from SourcePath to DestinationPath.
'
' Returns 0 if it could not find the file, or other runtime
' error occurs. Otherwise, returns true.
'
' If the source file is older, the function returns success (-1)
' even though no file was copied, since no error occurred.
'---------------------------------------------------------------
Function CopyFile (ByVal SourcePath As String, ByVal DestinationPath As String, ByVal SrcFilename As String, ByVal DestFileName As String)
' ----- VerInstallFile() flags -----
Const VIFF_FORCEINSTALL% = &H1, VIFF_DONTDELETEOLD% = &H2
Const OF_DELETE% = &H200
Const VIF_TEMPFILE& = &H1
Const VIF_MISMATCH& = &H2
Const VIF_SRCOLD& = &H4
Const VIF_DIFFLANG& = &H8
Const VIF_DIFFCODEPG& = &H10
Const VIF_DIFFTYPE& = &H20
Const VIF_WRITEPROT& = &H40
Const VIF_FILEINUSE& = &H80
Const VIF_OUTOFSPACE& = &H100
Const VIF_ACCESSVIOLATION& = &H200
Const VIF_SHARINGVIOLATION = &H400
Const VIF_CANNOTCREATE = &H800
Const VIF_CANNOTDELETE = &H1000
Const VIF_CANNOTRENAME = &H2000
Const VIF_CANNOTDELETECUR = &H4000
Const VIF_OUTOFMEMORY = &H8000
Const VIF_CANNOTREADSRC = &H10000
Const VIF_CANNOTREADDST = &H20000
Const VIF_BUFFTOOSMALL = &H40000
Dim TmpOFStruct As OFStruct
On Error GoTo ErrorCopy
Screen.MousePointer = 11
'--------------------------------------
' Add ending \ symbols to path variables
'--------------------------------------
If Right$(SourcePath$, 1) <> "\" Then
SourcePath$ = SourcePath$ + "\"
End If
If Right$(DestinationPath$, 1) <> "\" Then
DestinationPath$ = DestinationPath$ + "\"
End If
'----------------------------
' Update status dialog info
'----------------------------
Statusdlg.Label1.Caption = "Source file: " + Chr$(10) + Chr$(13) + UCase$(SourcePath$ + SrcFilename$)
Statusdlg.Label1.Refresh
Statusdlg.Label2.Caption = "Destination file: " + Chr$(10) + Chr$(13) + UCase$(DestinationPath$ + DestFileName$)
Statusdlg.Label2.Refresh
'-----------------------------------------
' Check the validity of the path and file
'-----------------------------------------
CheckForExist:
If Not FileExists(SourcePath$ + SrcFilename$) Then
Screen.MousePointer = 0
x% = MsgBox("Error occurred while attempting to copy file. Could not locate file: """ + SourcePath$ + SrcFilename$ + """", 34, "SETUP")
Screen.MousePointer = 11
If x% = 3 Then
CopyFile = False
ElseIf x% = 4 Then
GoTo CheckForExist
ElseIf x% = 5 Then
GoTo SkipThisFile
End If
Else
'-------------------------------------------------
' VerInstallFile installs the file. We need to initialize
' some arguments for the temp file that is created by the call
'-------------------------------------------------
TryToCopyAgain:
CurrDir$ = String$(255, 0)
TmpFile$ = String$(255, 0)
lpwTempFileLen% = 255
InFileVer$ = GetFileVersion(SourcePath$ + SrcFilename$)
OutFileVer$ = GetFileVersion(DestinationPath$ + DestFileName$)
' Install if no version info is available
If Len(InFileVer$) <> 0 And Len(OutFileVer$) <> 0 Then
' Don't install older or same version of file
If InFileVer$ <= OutFileVer$ And SourcePath <> DestinationPath Then
UpdateStatus GetFileSize(SourcePath$ + SrcFilename$)
CopyFile = True
Exit Function
End If
End If
Result& = VerInstallFile&(0, SrcFilename$, DestFileName$, SourcePath$, DestinationPath$, CurrDir$, TmpFile$, lpwTempFileLen%)
'--------------------------------------------
' After copying, update the installation meter
'---------------------------------------------
S$ = DestinationPath$
If Right$(S$, 1) <> "\" Then S$ = S$ + "\"
S$ = S$ + DestFileName$
If Not TryAgain% Then UpdateStatus GetFileSize(S$)
'--------------------------------
' There are many return values that you can test for.
' The constants are listed above.
' The following lines of code return will set the Function to
' True if the VerInstallFile call was successful.
'
' If the call was unsuccessful due to a different language on the
' users machine, VerInstallFile is called again to force installation.
' You can change this to not install if you choose.
' Be careful about using FORCEINSTALL. Other flags could be
' set which indicate that this file should not be overridden.
'
' Under any other circumstance, the tempfile created by VerInstallFile
' is removed using OpenFile and the CopyFile function returns false.
'--------------------------------------------------------
If Result& = 0 Or (Result& And VIF_SRCOLD&) = VIF_SRCOLD& Then
CopyFile = True
ElseIf (Result& And VIF_DIFFLANG&) = VIF_DIFFLANG& Then
Result& = VerInstallFile&(VIFF_FORCEINSTALL%, SrcFilename$, DestFileName$, SourcePath$, DestinationPath$, CurrDir$, TmpFile$, lpwTempFileLen%)
CopyFile = True
ElseIf (Result& And VIF_DIFFTYPE&) = VIF_DIFFTYPE& Then
'Fixes problem where the 3.0 version of THREED does not overwrite the 2.0 version
'Will fix any other problem where a file doesn't install because the type changed from one version to the next
Result& = VerInstallFile&(VIFF_FORCEINSTALL%, SrcFilename$, DestFileName$, SourcePath$, DestinationPath$, CurrDir$, TmpFile$, lpwTempFileLen%)
CopyFile = True
ElseIf (Result& And VIF_WRITEPROT&) = VIF_WRITEPROT& Then
Result& = VerInstallFile&(VIFF_FORCEINSTALL%, SrcFilename$, DestFileName$, SourcePath$, winSysDir$ + "\", CurrDir$, TmpFile$, lpwTempFileLen%)
CopyFile = True
ElseIf (Result& And VIF_CANNOTREADSRC) = VIF_CANNOTREADSRC Then
' VerInstallFile does will not handle compressed files that have been split.
' Use VB's FileCopy stmt
FileCopy SourcePath$ + SrcFilename$, DestinationPath$ + DestFileName$
CopyFile = True